package com.simple.proxy;

import com.simple.proxy.mybatis.db.DbTools;
import com.simple.proxy.mybatis.test.UserInfo;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class AppDriver {
    public static void main(String[] args) {
        String sql = "select * from user_info where id = ?";
        List<UserInfo> userInfos = DbTools.executeQuery(sql, UserInfo.class, 1);
        System.out.println(userInfos);

        UserInfo userInfo = new UserInfo();
        userInfo.setName("马云");
        userInfo.setAge(18);
        userInfo.setEmail("mayun@taobao.com");

        try {
            Connection connection = DbTools.getConnection();

            int row = DbTools.executeUpdate(connection,"insert into user_info(name,age,email) values(?,?,?)",userInfo.getName(),userInfo.getAge(),userInfo.getEmail());
            System.out.println(row);
        } catch (SQLException e) {
            e.printStackTrace();
        }





    }
}
